package com.example.demo.controller;

import com.example.demo.entity.Login;
import com.example.demo.entity.User;
import com.example.demo.service.LoginService;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.*;

import javax.jms.Queue;
import javax.jms.Topic;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@ServletComponentScan(basePackages = "com.example.filter")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private LoginService loginService;
    @RequestMapping("/userList")
    public Map<String, Object> userList(HttpServletRequest httpServletRequest, User user){
        return userService.userList(httpServletRequest,user);
    }
    @RequestMapping("/saveUser")
    public int saveUser(@RequestBody User user)
    {
        System.out.println("isdelete:"+user.getIsDelete());
        return userService.saveUser(user);
    }

    @RequestMapping("/loginUser")
    public Login userLogin(Login login)
    {
        return loginService.login(login);
    }


//    @RequestMapping("/hello")
//    public String hello() {
//        //这边我们,默认是返到templates下的login.html
//        return "login";
//    }
//    @RequestMapping("/updateUser")
//    public int updateUser(@RequestBody User user)
//    {
//        return userService.updateUser(user);
//    }
}
